<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <base target="_self"/>
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var stateValue="";
    $().ready(function(){
    selectSccj();
			var options = {
		  	    url:'<%=request.getContextPath() %>/sparePartsAction!saveFaqiRk.action',
		  	     beforeSubmit: function() {
		   				return checking();
		    			},
		  	    dataType:'json',
		  	    success: function(data) {
		  	      if(data.result=='success'){
					alert("添加成功");
					api.close();
					W.reload();
		  	      }
		  	    }};
		$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 });
    	$('#closeBtn').click(function(){
    		api.close();
		});
	});
	
   	function checking(){
   		var flag = true;
   		var equipmentOrgName =  $.trim($("#equipmentOrgName").val());
		var equipmentName = $.trim($("#equipmentName").val());
		var equipmentNo = $.trim($("#equipmentNo").val());
		var equipmentGgxh = $.trim($("#equipmentGgxh").val());
		var equipmentDw = $.trim($("#equipmentDw").val());
		if(equipmentOrgName ==null || equipmentOrgName == "" ){
			alert("部门不能为空！");
			$("#equipmentOrgName").focus();
    		return false;
		}
		if(equipmentName ==null || equipmentName == "" ){
			alert("设备名称不能为空！");
			$("#equipmentName").focus();
    		return false;
		}
		if(equipmentNo ==null || equipmentNo == "" ){
			alert("设备编号不能为空！");
			$("#equipmentNo").focus();
    		return false;
		}
		if(equipmentGgxh ==null || equipmentGgxh == "" ){
			alert("规格型号不能为空！");
			$("#equipmentGgxh").focus();
    		return false;
		}
		if(equipmentDw ==null || equipmentDw == "" ){
			alert("单位不能为空！");
			$("#equipmentDw").focus();
    		return false;
		}
		var equipmentCfd = $.trim($("#equipmentCfd").val());
		var equipmentCcbh = $.trim($("#equipmentCcbh").val());
		var equipmentFzr = $.trim($("#equipmentFzr").val());
		var equipmentLxfs = $.trim($("#equipmentLxfs").val());
		var equipmentJgqqsrq = $.trim($("#equipmentJgqqsrq").val());
		if(equipmentCfd ==null || equipmentCfd == "" ){
			alert("存放地点不能为空！");
			$("#equipmentCfd").focus();
    		return false;
		}
		if(equipmentCcbh ==null || equipmentCcbh == "" ){
			alert("出厂编号不能为空！");
			$("#equipmentCcbh").focus();
    		return false;
		}
		if(equipmentFzr ==null || equipmentFzr == "" ){
			alert("负责人不能为空！");
			$("#equipmentFzr").focus();
    		return false;
		}
		if(equipmentLxfs ==null || equipmentLxfs == "" ){
			alert("联系方式不能为空！");
			$("#equipmentLxfs").focus();
    		return false;
		}
		if(equipmentJgqqsrq ==null || equipmentJgqqsrq == "" ){
			alert("监管期起始日期不能为空！");
			$("#equipmentJgqqsrq").focus();
    		return false;
		}
		
		var equipmentJgqjsrq = $.trim($("#equipmentJgqjsrq").val());
		var equipmentGdzcbh = $.trim($("#equipmentGdzcbh").val());
		var equipmentTxsj = $.trim($("#equipmentTxsj").val());
		if(equipmentJgqjsrq ==null || equipmentJgqjsrq == "" ){
			alert("监管期结束日期不能为空！");
			$("#equipmentJgqjsrq").focus();
    		return false;
		}
		if(equipmentGdzcbh ==null || equipmentGdzcbh == "" ){
			alert("固定资产编号不能为空！");
			$("#equipmentGdzcbh").focus();
    		return false;
		}
		if(equipmentTxsj ==null || equipmentTxsj == "" ){
			alert("提醒时间不能为空！");
			$("#equipmentTxsj").focus();
    		return false;
		}else if(parseInt(equipmentTxsj)!=equipmentTxsj){
			  alert("提醒时间只能输入整数");
			  $("#equipmentTxsj").focus();
			  return false;
		}
	}
	 
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
			return false;
		}
		return true;
	}
	function checkNum(inputData){
		var sNumber;
	    sNumber=Number(inputData);
	    if (isNaN(inputData)){
	       return false;
	     }
	    return true;
	}
	function countlen1(textarea){
	       var elem = event.relatedTarget || event.srcElement || event.target ||event.currentTarget;    
	        if(event.keyCode!=8)
			{
			  if (textarea.value.length> 249){
			        alert("最多为250个字符,字符输入超出限制!");
			        textarea.value=textarea.value.substring(0,249);
			    }
			    return true;
	 	    }
	}
		
	  //选择部门
	function selectdept(id)
	{
		var datas = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("org_name").value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
	//选择人员
	function selectperson(id)
	{
		//if('${formid}'==3521&&id=='T_ZERENREN'){   
		    var users = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/selectUserByRole.jsp?roleid=590", window, "dialogWidth:500px;status:no;dialogHeight:500px");
		    document.getElementById("partOperator_name").value = users.username;
            document.getElementById(id).value = users.userid;
		/*}else{
		 var users = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/chooseAllUser.jsp", window, "dialogWidth:930px;status:no;dialogHeight:500px");
   	 	 if (users != null) {
   		    var userIds = [];
            var userNames = [];
            for(var i=0;i<users.length;i++){
               userIds.push(users[i]['userid']);
               userNames.push(users[i]['username']);
            }
            document.getElementById("user_"+id).value = userNames.join();
            document.getElementById(id).value = userIds.join();
    	  }
    	}*/
	}
	//选择备件
	function selectBeiJian(id){
		var datas = window.showModalDialog("<%=request.getContextPath() %>/view/choose_equipment_bj.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("partCode").value = json1.T_BJDM;
			 document.getElementById("partAttribute").value = json1.T_BJSX;
			 document.getElementById("partLevel").value = json1.T_BJDJ;
			 document.getElementById("partModel").value = json1.T_GGXH;
			 document.getElementById("partBrand").value = json1.T_PINPAI;
			 document.getElementById("partSupplier").value = json1.T_GONGYS;
			 document.getElementById("partMaxInventory").value = json1.T_ZDKC;
			 document.getElementById("partMinInventory").value = json1.T_ZXKC;
			 document.getElementById("partInventory").value = json1.T_SJKC;
			 document.getElementById("partMeasuringUnit").value = json1.T_JLDW;
			 document.getElementById("partEquipmentName").value = json1.T_SYSB;
			 document.getElementById("partEquipmentNo").value = json1.T_SYSBBH;
			 document.getElementById("partLocation").value = json1.T_CFDD;
			 document.getElementById("partName").value = json1.T_BJMC;
			 document.getElementById("partBjId").value = json1.ID;
			 document.getElementById("partEquId").value = json1.equ_id;
			 document.getElementById("partSupplierId").value = json1.gys_id;
		}
	}
   </script>
 	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  	
		.formTableNew textarea{border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>
  </head>
  
  <body>
<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
        <input type="hidden" id="partEquId" name="partEquId"  value="" />
        <input type="hidden" id="partSupplierId" name="partSupplierId" value="" />
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
  		<input id="partRkId" type="hidden" name="sparePartsRk.id" value="${requestScope.partRkId}"/>
  			<tr>
  			  <td align="right">入库单号：</td>
  			  <td align="left">
  			    <input  type="text" readonly  id="rkdh" maxlength="50" name="sparePartsRk.partReceiptNo" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="${requestScope.rkdh }" />
  			  	<input type="hidden" id="equipmentOrgId" name="sparePartsRk.equipmentOrgId" value="${requestScope.org_id }"/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">入库日期：</td>
  			  <td align="left">
  			    <input  type="text"  id="partInboundDate" maxlength="50" name="sparePartsRk.partInboundDate" onClick="WdatePicker({maxDate:new Date()})" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">入库类型：</td>
  			  <td align="left">
  			  	<select id="partStorageType" class='fselect' name="sparePartsRk.partStorageType" class='easyui-validatebox' style="border: 1px solid #999;padding: 5px;width:250px;height:25px;" >
 			      <option value="采购">采购</option>
			 	  <option value="随机">随机</option>
			 	  <option value="借用归还">借用归还</option>
			 	  <option value="回收">回收</option>
			 	  <option value="自制">自制</option>
			 	  <option value="其他">其他</option>
 			    </select>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">仓库名称：</td>
  			  <td align="left">
  			    <input  type="text"  id="org_name" maxlength="50" name="org_name" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<input type="hidden" id="partWarehouseName" name="sparePartsRk.partWarehouseName" value=""/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  	<img src="/gwm/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectdept('partWarehouseName')" />
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">仓管员：</td>
  			  <td align="left">
  			    <input  type="text"  id="partOperator_name" maxlength="50" name="partOperator_name" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<input type="hidden" id="partOperator" name="sparePartsRk.partOperator" value=""/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  	<img src="/gwm/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectperson('partOperator')" />
  			  </td>
  			  <td align="right">申请部门：</td>
  			  <td align="left">
  			    <input  type="text"  id="dept_name" maxlength="50" name="dept_name" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="<%=request.getSession().getAttribute("USER_DEPT_NAME") %>" />
  			  	<input type="hidden" id="partApplyDept" name="sparePartsRk.partApplyDept" value="<%=request.getSession().getAttribute("USER_DEPT") %>"/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			
  			<tr>
  			  <td align="right">申请人：</td>
  			  <td align="left">
  			    <input  type="text"  id="sqrName" maxlength="50" name="sqrName" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="<%=request.getSession().getAttribute("username") %>" />
  			  	<input type="hidden" id="partApplicant" name="sparePartsRk.partApplicant" value="<%=request.getSession().getAttribute("TDM_USER_ID") %>"/>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">备件代码：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partCode" maxlength="50" name="sparePartsRk.partCode" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<input  type="hidden"  id="partBjId" maxlength="50" name="sparePartsRk.partBjId" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			 	<img src="/gwm/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectBeiJian('partBjId')" />
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">备件名称：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partName" maxlength="50" name="sparePartsRk.partName" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">备件属性：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partAttribute" maxlength="50" name="sparePartsRk.partAttribute" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">备件等级：</td>
  			  <td align="left">
  			    <input  type="text"  id="partLevel"  name="sparePartsRk.partLevel"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">规格型号：</td>
  			  <td align="left">
  			    <input  type="text"  id="partModel"  name="sparePartsRk.partModel"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">品牌：</td>
  			  <td align="left">
  			  <input  type="text"  id="partBrand"  name="sparePartsRk"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">供应商：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partSupplier"  name="sparePartsRk.partSupplier"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">单价：</td>
  			  <td align="left">
  			    <input  type="text"  id="partPrice"  name="sparePartsRk.partPrice"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">入库数量：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partCount"  name="sparePartsRk.partCount"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">入库金额：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partAmount"  name="sparePartsRk.partAmount"   style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">采购周期：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partCycle"  name="sparePartsRk.partCycle" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'equipmentJgqjsrq\');}'})" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			
  			<tr>
  			  <td align="right">最大库存：</td>
  			  <td align="left">
  			    <input  type="text"  id="partMaxInventory"  name="sparePartsRk.partMaxInventory" onClick="WdatePicker({minDate:'#F{$dp.$D(\'equipmentJgqqsrq\');}'})" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">最小库存：</td>
  			  <td align="left">
  			  	 <input  type="text"  id="partMinInventory"   maxlength="50" name="sparePartsRk.partMinInventory" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">实际库存：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partInventory" maxlength="3" name="sparePartsRk.partInventory"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">计量单位：</td>
  			  <td align="left">
  			  	 <input  type="text"  id="partMeasuringUnit" maxlength="3" name="sparePartsRk.partMeasuringUnit"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">适用设备：</td>
  			  <td align="left">
  			  	<input  type="text"  id="partEquipmentName" maxlength="3" name="sparePartsRk.partEquipmentName"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <td align="right">适用设备编号：</td>
  			  <td align="left">
  			  	 <input  type="text"  id="partEquipmentNo" maxlength="50" name="sparePartsRk.partEquipmentNo"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">存放地点：</td>
  			  <td align="left">
  			  	<input  type="text"   id="partLocation" maxlength="3" name="sparePartsRk.partLocation"  style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
 			<tr>
 				<td align="right"  >备注：</td>
			    <td colspan="3">
			    	<div class="div">
						<textarea rows="5" cols="100" id="partRemark" name="sparePartsRk.partRemark" onkeydown="countlen1(this);" style="width: 726px;"></textarea>
					</div>	
			    </td>
		    </tr>
		</table>
		<table width="100%" border="0" align="center" class="formTableNew">
		  <tr>
			<td align="center">
		    	<input id="saveBtn" type="button" value="提 交" class="form_bt_orange" />
		    	<input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
	<!--表单结束-->
	</form>
  </body>
</html>
